package NativeInterface;

import java.util.LinkedList;




public class NativeInterface {

	
	private LinkedList<NativeFunction> NativeFunctionList = new LinkedList<NativeFunction>() ;  	

	
	
	
public NativeInterface()
{
	

	NativeFunctionList.add(new NativeFunction("sleep", "java/lang/Thread","(J)V",(short)0));
	
	
	
	NativeFunctionList.add(new NativeFunction("valueOf", "java/lang/String","(I)Ljava/lang/String;",(short)2)); 
	NativeFunctionList.add(new NativeFunction("valueOf", "java/lang/String","(F)Ljava/lang/String;",(short)3));
	NativeFunctionList.add(new NativeFunction("valueOf", "java/lang/String","(D)Ljava/lang/String;",(short)4));
	
	NativeFunctionList.add(new NativeFunction("get", "utils/RandomNumber","()I",(short)0x0e));
	NativeFunctionList.add(new NativeFunction("getRange", "utils/RandomNumber","(I)I",(short)0x0F));
	
	
	NativeFunctionList.add(new NativeFunction("print", "java/io/Console","(C)V",(short)0x10));
	
	NativeFunctionList.add(new NativeFunction("on", "hardware/LED","(I)V",(short)0x20));
	NativeFunctionList.add(new NativeFunction("off", "hardware/LED","(I)V",(short)0x21));
	NativeFunctionList.add(new NativeFunction("toggle", "hardware/LED","(I)V",(short)0x22));
	
	
	NativeFunctionList.add(new NativeFunction("keyLUp", "hardware/UI","()Z",(short)0x30));
	NativeFunctionList.add(new NativeFunction("keyLDown", "hardware/UI","()Z",(short)0x31));
	NativeFunctionList.add(new NativeFunction("keyLLeft", "hardware/UI","()Z",(short)0x32));
	NativeFunctionList.add(new NativeFunction("keyLRight", "hardware/UI","()Z",(short)0x33));
	
	NativeFunctionList.add(new NativeFunction("keyRUp", "hardware/UI","()Z",(short)0x34));
	NativeFunctionList.add(new NativeFunction("keyRDown", "hardware/UI","()Z",(short)0x35));
	NativeFunctionList.add(new NativeFunction("keyRLeft", "hardware/UI","()Z",(short)0x36));
	NativeFunctionList.add(new NativeFunction("keyRRight", "hardware/UI","()Z",(short)0x37));
	NativeFunctionList.add(new NativeFunction("keyPressed", "hardware/UI","(B)Z",(short)0x38));
	NativeFunctionList.add(new NativeFunction("getAccAxis", "hardware/UI","(B)B",(short)0x39));

	
	NativeFunctionList.add(new NativeFunction("setPixel", "hardware/Display2D","(IIS)V",(short)0x40));
	NativeFunctionList.add(new NativeFunction("clear", "hardware/Display2D","()V",(short)0x41));
	NativeFunctionList.add(new NativeFunction("setTopLED", "hardware/Display2D","(IS)V",(short)0x42));
	NativeFunctionList.add(new NativeFunction("getRowCount", "hardware/Display2D","()I",(short)0x43));
	NativeFunctionList.add(new NativeFunction("getColumnCount", "hardware/Display2D","()I",(short)0x44));
	NativeFunctionList.add(new NativeFunction("doRepaint", "hardware/Display2D","()V",(short)0x45));
	NativeFunctionList.add(new NativeFunction("setSideLED", "hardware/Display2D","(IS)V",(short)0x46));
	NativeFunctionList.add(new NativeFunction("fillAll", "hardware/Display2D","(S)V",(short)0x47));
	NativeFunctionList.add(new NativeFunction("print5x5Char", "hardware/Display2D","(CSII)V",(short)0x48));
	NativeFunctionList.add(new NativeFunction("print8x8Char", "hardware/Display2D","(CSII)V",(short)0x49));
	NativeFunctionList.add(new NativeFunction("drawLine", "hardware/Display2D","(IIIIS)V",(short)0x4A));
	NativeFunctionList.add(new NativeFunction("_display2DBitmap", "hardware/Display2D","(II[S)V",(short)0x4B));
	
	
	NativeFunctionList.add(new NativeFunction("playSound", "hardware/Buzzer","()V",(short)0x50));
	
	
	
	NativeFunctionList.add(new NativeFunction("_fill", "graphics/Bitmap2D","([SS)V",(short)0x60));
	NativeFunctionList.add(new NativeFunction("_setPixel", "graphics/Bitmap2D","(II[SS)V",(short)0x61));
	NativeFunctionList.add(new NativeFunction("_getPixel", "graphics/Bitmap2D","(II[S)S",(short)0x62));
	NativeFunctionList.add(new NativeFunction("_mirror", "graphics/Bitmap2D","(I[S)V",(short)0x64));

//	NativeFunctionList.add(new NativeFunction("_rotate", "graphics/Bitmap2D","(CSII)V",(short)0x64));
	NativeFunctionList.add(new NativeFunction("_print5x5Char", "graphics/Bitmap2D","([SCSII)Z",(short)0x65));
	NativeFunctionList.add(new NativeFunction("_print8x8Char", "graphics/Bitmap2D","([SCSII)Z",(short)0x66));
	
	NativeFunctionList.add(new NativeFunction("_not", "graphics/Bitmap2D","([S)V",(short)0x67));
	NativeFunctionList.add(new NativeFunction("_min", "graphics/Bitmap2D","([S[S)V",(short)0x68));
	NativeFunctionList.add(new NativeFunction("_max", "graphics/Bitmap2D","([S[S)V",(short)0x69));
	NativeFunctionList.add(new NativeFunction("_copy", "graphics/Bitmap2D","([S[S)V",(short)0x70));
	
	

	
	
	
	

}




public NativeFunction findFunction(String functionName, String className, String parameters)  
{
	int index;
	
	
	for (index=0;index<NativeFunctionList.size();index++)
	{
		if (NativeFunctionList.get(index).isMatch(functionName,className,parameters))
			{
			return(NativeFunctionList.get(index));
			}
	}
		
	
	return(null);
}



}
